package com.cskaoyan.aspecj;

import com.cskaoyan.bean.common.BaseRespVo;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @Author: zhang
 * @Date: 2022/11/22 16:20
 * @Since: jdk1.8
 */
@Component
@Aspect
public class ValidationAspect {
    @Pointcut("execution(com.cskaoyan.bean.common.BaseRespVo com.cskaoyan..Validation.*(..) )")
    public void pointcut1() {
    }

    @AfterThrowing(value = "pointcut1()", throwing = "exception")
    public BaseRespVo<Object> processIllegalArgument(Exception exception) {
        String message = exception.getMessage();
        return BaseRespVo.invalidParameter(message);
    }
}
